home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Crosscountry USA Photo Safari
/
Crosscountry USA Photo Safari.iso
/
Data
/
cc_base
/
pak00_16bit_f.pk3
/
common
/
destination_arrived.c4
< prev
next >
Wrap
Text File
|
2003-01-03
|
12KB
|
242 lines
{
@destination_arrived {
resid Player;
resid Game;
resid CurCommodity;
resid Scenario;
str nav_cur_city;
str destination_city;
str game_stats;
str instruction;
int num_commodities;
int i;
int tmp_int;
str tmp_str;
str start_date;
str end_date;
int commodity_cost;
int bonus_commodity_cost;
int commodity_revenue;
str commodity_revenue_str;
int total_income;
str total_income_str;
int truck_lease_cost_per_day;
int truck_meter_cost_per_mile;
int truck_trip_meter_cost;
int truck_lease_cost;
int truck_lease_total_cost;
str truck_lease_total_cost_str;
str total_expense_str;
int total_expense;
int fuel_expense;
str fuel_expense_str;
int food_expense;
str food_expense_str;
int hotel_expense;
str hotel_expense_str;
int mishap_expense;
str mishap_expense_str;
int ticket_expense;
str ticket_expense_str;
int total;
str total_str;
str commodity_str;
Game = ResByName("Game");
Player = ResPropGetResID(Game,"game_cur_player");
Scenario = ResPropGetResID(Player,"scenario_id");
destination_city = ResPropGetStr(Scenario,"scenario_end_city");
nav_cur_city = ResPropGetStr(Player,"nav_cur_city");
num_commodities = ResPropGetInt(Scenario,"scenario_commodity_number_of");
/* stop if this city is not the destination city */
if (! StrExact(nav_cur_city,destination_city)) {
stop;
}
if (ResPropGetInt(Player, "player_destination_arrived") == 1) { stop; }
i = 1;
while (i <= num_commodities) {
CurCommodity = ResPropGetResID(Player,StrFormatStr("commodity_%d",i));
if (ResPropGetInt(CurCommodity,"commodity_state") != 1) {
stop;
}
i += 1;
}
/* print the game stats to the travel log */
StrListAppend( ResPropGetResID(Player, "travel_log"), "-----------------------------------------------------------------");
tmp_int = ResPropGetInt(Scenario,"scenario_start_date");
start_date = StrFormatStr("%s %d, %d", StrCapFirst(TimeGetMonthStr(tmp_int)), TimeGetDay(tmp_int), TimeGetYear(tmp_int));
tmp_int = ResPropGetInt(Player,"time_now");
tmp_int += (ResPropGetInt(Player,"time_zone_clock_offset") * 60);
end_date = StrFormatStr("%s %d, %d", StrCapFirst(TimeGetMonthStr(tmp_int)), TimeGetDay(tmp_int), TimeGetYear(tmp_int));
StrListAppend( ResPropGetResID(Player, "travel_log"), " ");
StrListAppend( ResPropGetResID(Player, "travel_log"), "Assignment:");
StrListAppend( ResPropGetResID(Player, "travel_log"), StrFormatStr(MangleSIDToStr(274/*" Driver: %s"*/), ResPropGetStr(Player,"player_name")));
StrListAppend( ResPropGetResID(Player, "travel_log"), StrFormatStr(MangleSIDToStr(275/*" Start Location: %s"*/), ResPropGetStr(Scenario,"scenario_start_city")));
StrListAppend( ResPropGetResID(Player, "travel_log"), StrFormatStr(MangleSIDToStr(276/*" Destination: %s"*/), ResPropGetStr(Scenario,"scenario_end_city")));
StrListAppend( ResPropGetResID(Player, "travel_log"), StrFormatStr(MangleSIDToStr(277/*" Start Date: %s"*/), start_date));
StrListAppend( ResPropGetResID(Player, "travel_log"), StrFormatStr(MangleSIDToStr(278/*" End Date: %s"*/), end_date));
StrListAppend( ResPropGetResID(Player, "travel_log"), StrFormatStr(MangleSIDToStr(279/*" Total Mileage: %d %s"*/), ResPropGetInt(Player,"truck_trip_meter"), ResPropGetStr(Game,"game_distance_unit")));
StrListAppend( ResPropGetResID(Player, "travel_log"), StrFormatStr(MangleSIDToStr(280/*" Bonus Commodity: %s"*/), ResPropGetStr(Scenario,"scenario_commodity_bonus")));
if (!StrExact(ResPropGetStr(Scenario,"scenario_commodity_name_1"),"")) {
commodity_str = ResPropGetStr(Scenario,"scenario_commodity_name_1");
}
if (!StrExact(ResPropGetStr(Scenario,"scenario_commodity_name_2"),"")) {
commodity_str = StrFormatStr("%s, %s",commodity_str,ResPropGetStr(Scenario,"scenario_commodity_name_2"));
}
if (!StrExact(ResPropGetStr(Scenario,"scenario_commodity_name_3"),"")) {
commodity_str = StrFormatStr("%s, %s",commodity_str,ResPropGetStr(Scenario,"scenario_commodity_name_3"));
}
if (!StrExact(ResPropGetStr(Scenario,"scenario_commodity_name_4"),"")) {
commodity_str = StrFormatStr("%s, %s",commodity_str,ResPropGetStr(Scenario,"scenario_commodity_name_4"));
}
if (!StrExact(ResPropGetStr(Scenario,"scenario_commodity_name_5"),"")) {
commodity_str = StrFormatStr("%s, %s",commodity_str,ResPropGetStr(Scenario,"scenario_commodity_name_5"));
}
if (!StrExact(ResPropGetStr(Scenario,"scenario_commodity_name_6"),"")) {
commodity_str = StrFormatStr("%s, %s",commodity_str,ResPropGetStr(Scenario,"scenario_commodity_name_6"));
}
if (!StrExact(ResPropGetStr(Scenario,"scenario_commodity_name_7"),"")) {
commodity_str = StrFormatStr("%s, %s",commodity_str,ResPropGetStr(Scenario,"scenario_commodity_name_7"));
}
if (!StrExact(ResPropGetStr(Scenario,"scenario_commodity_name_8"),"")) {
commodity_str = StrFormatStr("%s, %s",commodity_str,ResPropGetStr(Scenario,"scenario_commodity_name_8"));
}
if (!StrExact(ResPropGetStr(Scenario,"scenario_commodity_name_9"),"")) {
commodity_str = StrFormatStr("%s, %s",commodity_str,ResPropGetStr(Scenario,"scenario_commodity_name_9"));
}
if (!StrExact(ResPropGetStr(Scenario,"scenario_commodity_name_10"),"")) {
commodity_str = StrFormatStr("%s, %s",commodity_str,ResPropGetStr(Scenario,"scenario_commodity_name_10"));
}
if (!StrExact(ResPropGetStr(Scenario,"scenario_commodity_name_11"),"")) {
commodity_str = StrFormatStr("%s, %s",commodity_str,ResPropGetStr(Scenario,"scenario_commodity_name_11"));
}
if (!StrExact(ResPropGetStr(Scenario,"scenario_commodity_name_12"),"")) {
commodity_str = StrFormatStr("%s, %s",commodity_str,ResPropGetStr(Scenario,"scenario_commodity_name_12"));
}
StrListAppend( ResPropGetResID(Player, "travel_log"), StrFormatStr(MangleSIDToStr(281/*" Commodities: %s"*/),commodity_str));
StrListAppend( ResPropGetResID(Player, "travel_log"), " ");
StrListAppend( ResPropGetResID(Player, "travel_log"), MangleSIDToStr(282/*"Income:"*/));
/* get number of commodity player picked up */
commodity_cost = ResPropGetInt(Game,"game_salary_per_commodity");
bonus_commodity_cost = ResPropGetInt(Game,"game_salary_bonus_commodity");
commodity_revenue = ResPropGetInt(Player,"commodity_number_of") * commodity_cost;
/* check bonus commodity */
if (ResPropGetInt(ResPropGetResID(Player, "commodity_bonus"),"commodity_state") == 1) {
commodity_revenue += bonus_commodity_cost;
}
commodity_revenue_str = StrFormatStr(MangleSIDToStr(283/*"$ %s"*/), IntToDecimalStr(commodity_revenue,100));
total_income = commodity_revenue + ResPropGetInt(Player, "expense_cash_in_hand");
total_income_str = StrFormatStr(MangleSIDToStr(284/*"$ %s"*/), IntToDecimalStr(total_income,100));
StrListAppend( ResPropGetResID(Player, "travel_log"), StrFormatStr(MangleSIDToStr(285/*" Starting Balance: $%s\n"*/), IntToDecimalStr(ResPropGetInt(Player, "expense_cash_in_hand"),100)));
StrListAppend( ResPropGetResID(Player, "travel_log"), StrFormatStr(MangleSIDToStr(286/*" Commodity Revenue: %s\n"*/), commodity_revenue_str));
StrListAppend( ResPropGetResID(Player, "travel_log"), StrFormatStr(MangleSIDToStr(287/*" Total Income: %s\n"*/), total_income_str));
StrListAppend( ResPropGetResID(Player, "travel_log"), " ");
StrListAppend( ResPropGetResID(Player, "travel_log"), MangleSIDToStr(288/*"Expenses:"*/));
truck_lease_cost_per_day = ResPropGetInt(Game,"game_truck_lease_cost_per_day");
truck_meter_cost_per_mile = ResPropGetInt(Game,"game_truck_meter_cost_per_mile");
food_expense = ResPropGetInt(Player, "expense_spent_on_food");
total_expense += food_expense;
food_expense_str = StrFormatStr("($ %s)", IntToDecimalStr(food_expense,100));
fuel_expense = ResPropGetInt(Player, "expense_spent_on_fuel");
fuel_expense += ((ResPropGetInt(Game,"game_tank_capacity") - ResPropGetInt(Player,"truck_fuel_remaining")) * ResPropGetInt(Game,"game_fuel_unit_cost")) / 1000;
ResPropSetInt(Player,"truck_fuel_remaining",ResPropGetInt(Game,"game_tank_capacity"));
ResPropSetInt(Player, "expense_spent_on_fuel",fuel_expense);
total_expense += fuel_expense;
fuel_expense_str = StrFormatStr("($ %s)", IntToDecimalStr(fuel_expense,100));
hotel_expense = ResPropGetInt(Player, "expense_spent_on_hotel");
total_expense += hotel_expense;
hotel_expense_str = StrFormatStr("($ %s)", IntToDecimalStr(hotel_expense,100));
mishap_expense = ResPropGetInt(Player, "expense_spent_on_mishap");
total_expense += mishap_expense;
mishap_expense_str = StrFormatStr("($ %s)", IntToDecimalStr(mishap_expense,100));
ticket_expense = ResPropGetInt(Player, "expense_spent_on_ticket");
total_expense += ticket_expense;
ticket_expense_str = StrFormatStr("($ %s)", IntToDecimalStr(ticket_expense,100));
/* display truck lease cost */
truck_trip_meter_cost = ResPropGetInt(Player, "truck_trip_meter") * truck_meter_cost_per_mile;
truck_lease_cost = (TimeGetDay(ResPropGetInt(Player, "time_now"))-1) * truck_lease_cost_per_day;
truck_lease_total_cost = (truck_trip_meter_cost + truck_lease_cost)/10;
total_expense += truck_lease_total_cost;
truck_lease_total_cost_str = StrFormatStr("($ %s)", IntToDecimalStr(truck_lease_total_cost,100));
total_expense_str = StrFormatStr("($ %s)", IntToDecimalStr(total_expense,100));
StrListAppend( ResPropGetResID(Player, "travel_log"), StrFormatStr(MangleSIDToStr(289/*" Food Cost: %s"*/), food_expense_str));
StrListAppend( ResPropGetResID(Player, "travel_log"), StrFormatStr(MangleSIDToStr(290/*" Fuel / Ferry Cost: %s"*/), fuel_expense_str ));
StrListAppend( ResPropGetResID(Player, "travel_log"), StrFormatStr(MangleSIDToStr(291/*" Lodging Cost: %s"*/), hotel_expense_str));
StrListAppend( ResPropGetResID(Player, "travel_log"), StrFormatStr(MangleSIDToStr(292/*" Mishap Cost: %s"*/), mishap_expense_str));
StrListAppend( ResPropGetResID(Player, "travel_log"), StrFormatStr(MangleSIDToStr(293/*" Ticket Cost: %s"*/), ticket_expense_str));
StrListAppend( ResPropGetResID(Player, "travel_log"), StrFormatStr(MangleSIDToStr(294/*" Truck Lease: %s"*/), truck_lease_total_cost_str));
StrListAppend( ResPropGetResID(Player, "travel_log"), StrFormatStr(MangleSIDToStr(295/*" Total Expenses: %s"*/), total_expense_str));
total = total_income - total_expense;
if ( total < 0 ) {
total *= -1;
total_str = StrFormatStr("($ %s)", IntToDecimalStr(total,100));
} else {
total_str = StrFormatStr("$ %s", IntToDecimalStr(total,100));
}
StrListAppend( ResPropGetResID(Player, "travel_log"), " ");
StrListAppend( ResPropGetResID(Player, "travel_log"), StrFormatStr(MangleSIDToStr(296/*"Profit / (Loss): %s"*/), total_str));
StrListAppend( ResPropGetResID(Player, "travel_log"), " ");
StrListAppend( ResPropGetResID(Player, "travel_log"), MangleSIDToStr(297/*"Congratulations, you have successfully completed your assignment!"*/));
/* set the dest flag */
ResPropSetInt(Player,"player_destination_arrived",1);
/* load full screen animation */
ResPropSetStr(Player, "nav_picture", "victory");
ResPropSetStr(Player, "nav_sound", "victory");
ResPropSetInt(Player, "nav_switch_player", 1);
ResPropSetInt(Player, "nav_picture_no_dash_flag", 1);
ResPropSetInt(ResByName("dash.gl/full_screen"), "Hidden", FALSE);
}
}